package com.bestcem.xm.component.mqmetrics.configure;

import com.bestcem.xm.component.mqmetrics.aspect.MqMetricsAspect;
import com.bestcem.xm.component.mqmetrics.properties.MqMetricProperties;
import com.bestcem.xm.component.mqmetrics.service.CustomMqMetricService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({MqMetricProperties.class})
@ConditionalOnProperty(prefix = "xm.mq.metrics", name = "enabled", havingValue = "true", matchIfMissing = false)
public class MqMetricsAutoConfigure {

    @Bean
    @ConditionalOnMissingBean
    public CustomMqMetricService customMqMetricService() {
        return new CustomMqMetricService();
    }

    @Bean
    @ConditionalOnMissingBean
    public MqMetricsAspect mqMetricsAspect() {
        return new MqMetricsAspect();
    }

}

